package com.yundingai.domain.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.util.Date;

/**
 * 自习室表：记录自习室相关信息及自习室设置选项
 * @TableName study_room
 */
@TableName(value ="study_room")
@Data
public class StudyRoom {
    /**
     * 房间id uuid+时间戳
     */
    @TableId
    private String roomId;

    /**
     * 分类id：目前默认标准配置0，之后有时间再拓展(关联room_category)可加类型1.2.3.。
     */
    private Integer catId;

    /**
     * 房间标题
     */
    private String roomTitle;

    /**
     * 房间描述
     */
    private String description;

    /**
     * 最大人数
     */
    private Integer maxSeat;
    /**
     * 状态：-1已关闭，0无人，1进行中，2活跃（人数大于x时更新为2）
更改为0时激活一个计时器，计时结束后销毁该聊天室
更改为1时检测进行中的计时器，如有则关闭计时器
     */
    private Integer roomStatus;

    /**
     * 公开性：0公开，1仅限好友，2仅限邀请
     */
    private Integer isPrivate;

    /**
     * 邀请码
     */
    private String inviteCode;

    /**
     * 暂时设置（EXPIRE）过期时间为12小时，43200秒
     */
    private String autoCloseMin;

    /**
     * 摄像头开关：0关闭，1开启
     */
    private Integer isCamera;

    /**
     * 麦克风开关：0关闭，1开启
     */
    private Integer isMic;

    /**
     * 共享屏幕开关：0关闭，1开启
     */
    private Integer isScreenShare;

    /**
     * 创建者
     */
    private String creator;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 修改人
     */
    private String updater;

    /**
     * 修改时间：is_end=1时更新，记录关闭时间
     */
    private Date updateTime;

    /**
     * 自习室在线人数
     */
    private Integer userCount;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        StudyRoom other = (StudyRoom) that;
        return (this.getRoomId() == null ? other.getRoomId() == null : this.getRoomId().equals(other.getRoomId()))
            && (this.getCatId() == null ? other.getCatId() == null : this.getCatId().equals(other.getCatId()))
            && (this.getRoomTitle() == null ? other.getRoomTitle() == null : this.getRoomTitle().equals(other.getRoomTitle()))
            && (this.getDescription() == null ? other.getDescription() == null : this.getDescription().equals(other.getDescription()))
            && (this.getMaxSeat() == null ? other.getMaxSeat() == null : this.getMaxSeat().equals(other.getMaxSeat()))
            && (this.getRoomStatus() == null ? other.getRoomStatus() == null : this.getRoomStatus().equals(other.getRoomStatus()))
            && (this.getIsPrivate() == null ? other.getIsPrivate() == null : this.getIsPrivate().equals(other.getIsPrivate()))
            && (this.getInviteCode() == null ? other.getInviteCode() == null : this.getInviteCode().equals(other.getInviteCode()))
            && (this.getAutoCloseMin() == null ? other.getAutoCloseMin() == null : this.getAutoCloseMin().equals(other.getAutoCloseMin()))
            && (this.getIsCamera() == null ? other.getIsCamera() == null : this.getIsCamera().equals(other.getIsCamera()))
            && (this.getIsMic() == null ? other.getIsMic() == null : this.getIsMic().equals(other.getIsMic()))
            && (this.getIsScreenShare() == null ? other.getIsScreenShare() == null : this.getIsScreenShare().equals(other.getIsScreenShare()))
            && (this.getCreator() == null ? other.getCreator() == null : this.getCreator().equals(other.getCreator()))
            && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
            && (this.getUpdater() == null ? other.getUpdater() == null : this.getUpdater().equals(other.getUpdater()))
            && (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()))
            && (this.getUserCount() == null ? other.getUserCount() == null : this.getUserCount().equals(other.getUserCount()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getRoomId() == null) ? 0 : getRoomId().hashCode());
        result = prime * result + ((getCatId() == null) ? 0 : getCatId().hashCode());
        result = prime * result + ((getRoomTitle() == null) ? 0 : getRoomTitle().hashCode());
        result = prime * result + ((getDescription() == null) ? 0 : getDescription().hashCode());
        result = prime * result + ((getMaxSeat() == null) ? 0 : getMaxSeat().hashCode());
        result = prime * result + ((getRoomStatus() == null) ? 0 : getRoomStatus().hashCode());
        result = prime * result + ((getIsPrivate() == null) ? 0 : getIsPrivate().hashCode());
        result = prime * result + ((getInviteCode() == null) ? 0 : getInviteCode().hashCode());
        result = prime * result + ((getAutoCloseMin() == null) ? 0 : getAutoCloseMin().hashCode());
        result = prime * result + ((getIsCamera() == null) ? 0 : getIsCamera().hashCode());
        result = prime * result + ((getIsMic() == null) ? 0 : getIsMic().hashCode());
        result = prime * result + ((getIsScreenShare() == null) ? 0 : getIsScreenShare().hashCode());
        result = prime * result + ((getCreator() == null) ? 0 : getCreator().hashCode());
        result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
        result = prime * result + ((getUpdater() == null) ? 0 : getUpdater().hashCode());
        result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
        result = prime * result + ((getUserCount() == null) ? 0 : getUserCount().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", roomId=").append(roomId);
        sb.append(", catId=").append(catId);
        sb.append(", roomTitle=").append(roomTitle);
        sb.append(", description=").append(description);
        sb.append(", maxSeat=").append(maxSeat);
        sb.append(", roomStatus=").append(roomStatus);
        sb.append(", isPrivate=").append(isPrivate);
        sb.append(", inviteCode=").append(inviteCode);
        sb.append(", autoCloseMin=").append(autoCloseMin);
        sb.append(", isCamera=").append(isCamera);
        sb.append(", isMic=").append(isMic);
        sb.append(", isScreenShare=").append(isScreenShare);
        sb.append(", creator=").append(creator);
        sb.append(", createTime=").append(createTime);
        sb.append(", updater=").append(updater);
        sb.append(", updateTime=").append(updateTime);
        sb.append(", userCount=").append(userCount);
        sb.append("]");
        return sb.toString();
    }
}